﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using System.Web.Script.Serialization;
using System.IO;

namespace WebBHXH.Entities
{
    class CoSoKCBModel
    {

        public CoSoKCBModel()
        {
        }
        public CoSoKCBModel(string json)
        {
            JObject jObject = JObject.Parse(json);
            maCoSoKCB = (string)jObject["Ma_CoSoKCB"];
            ten_CoSoKCB = (string)jObject["Ten_CoSoKCB"];
            diaChi = (string)jObject["DiaChi"];
            dienThoai = (string)jObject["DienThoai"];
            ghiChu = (string)jObject["GhiChu"];
        }

        public List<CoSoKCBModel> GetCoSoKCB()
        {
            System.Net.WebRequest request = System.Net.WebRequest.Create("" + Util.getUrl() + "Home/GetCoSoKCBModel");

            request.Method = "POST";
            request.ContentLength = 0;
            request.ContentType = "application/json; charset=utf-8";
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();
            //get response-stream, and use a streamReader to read the content
            List<CoSoKCBModel> listCoSoKCBModel = new List<CoSoKCBModel>();
            using (Stream s = request.GetResponse().GetResponseStream())
            {
                using (StreamReader sr = new StreamReader(s))
                {
                    JavaScriptSerializer jsonserializer = new JavaScriptSerializer();
                    listCoSoKCBModel = jsonserializer.Deserialize<List<CoSoKCBModel>>(sr.ReadToEnd());
                    return listCoSoKCBModel;
                }
            }

            return new List<CoSoKCBModel>();
        }

        private string maCoSoKCB;

        public string MaCoSoKCB
        {
            get { return maCoSoKCB; }
            set { maCoSoKCB = value; }
        }
        private string ten_CoSoKCB;

        public string Ten_CoSoKCB
        {
            get { return ten_CoSoKCB; }
            set { ten_CoSoKCB = value; }
        }
        private string diaChi;

        public string DiaChi
        {
            get { return diaChi; }
            set { diaChi = value; }
        }
        private string dienThoai;

        public string DienThoai
        {
            get { return dienThoai; }
            set { dienThoai = value; }
        }
        private string ghiChu;

        public string GhiChu
        {
            get { return ghiChu; }
            set { ghiChu = value; }
        }

    }
}
